/**
 * Vue3 Main script
 */

// Load vue core
import { createApp } from 'vue';
import router from './router';
import store from './store';

import { Directive } from 'vue'
// @ts-ignore
import * as directives from './directives'

// Load Vuetify
import vuetify from './plugins/vuetify';

import i18n from './plugins/i18n'

// Load Layout vue.
import App from './App.vue';

import './index.css'

import mitt from 'mitt'
const emitter = mitt()

import AOS from 'aos'
import 'aos/dist/aos.css'
AOS.init()


/** Register Vue */
const app = createApp(App)

// 注册自定义指令
Object.keys(directives).forEach((key) => {
  app.directive(key, (directives as { [key: string]: Directive })[key])
})

app.provide('emitter', emitter)

app.use(i18n).use(store).use(router).use(AOS).use(vuetify)
app.config.errorHandler = (err) => {
  console.log(err)
}

import VConsole from 'vconsole';

if(import.meta.env.DEV) {
  new VConsole();
}

// Run!
router.isReady().then(() => {
  app.mount('#app')
})
